#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#include"tcpsocket.h"

void Showusage()
{	
	printf("argv[1] server ip\n");
	printf("argv[2] server port\n");
}

int main(int argc,char * argv[])
{
	int ret = -1;
	if (argc<3)
	{
		Showusage();
		exit(0);
	}

	TcpSocket cli(argv[1],atoi(argv[2]));
	cli.Connect();
	
	// read buffer from stdin and send to server
	char str[512];
	char * flag = str;
	while(flag != NULL)
	{
		bzero(str,sizeof(str));
		gets(str);
		printf("u say:%s\n",str);
		cli.Write(str,strlen(str));
		bzero(str,sizeof(str));
		cli.Read(str,sizeof(str));
		printf("svr feed back:%s\n",str);
	}
	return ret;
}
